<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
  	<jsp:include page="../js_top.jsp"></jsp:include>

	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	  <style type="text/css">
		  .table_report{width:540px;margin:15px auto;}
		  .table_report tr td{line-height:31px;color:#63666d;font-size:14px;font-family:Arial,Helvetica,"微软雅黑";}
		  .table_report tr td a{width:185px;height:38px;line-height:38px;-webkit-border-radius:5px;border-radius:5px;border-color:#b7bacb;display:block;font-size:14px;font-family:"微软雅黑";text-shadow:0 0px 0 rgba(0,0,0,0)!important;background:#b7bacb url(/static/img/images/table_report_icon1.png) no-repeat 70px center;text-align:center;color:#fff;cursor:pointer;text-indent:20px;float:left;margin:0 20px 0 0;}

		  .table_report tr td a:hover,.table_report tr:last-child td:last-child a:hover{background-color:#0fb1d6;text-decoration:none;}
		  input:focus:invalid:focus, textarea:focus:invalid:focus, select:focus:invalid:focus{border-color:#f59942;}
	  </style>
  

  </head>
  
  <body>
    <form action="" id="saveForm" name="saveForm" method="post">
    	<input type="hidden" name="id" id="id" value="${hospital.id}" />
    	<table class="table  table-striped table-hover table_report">
    			<tr>
    				<td >医院名称</td>
    				<td><input type="text" name="name" id="name" value="${hospital.name}" placeholder="必填"  required="true"/></td>
    				<td>医院类型</td>
					<td>
						<select class="form-control" id="type" name="type">
							<option value="1">一级医院</option>
							<option value="2">二级医院</option>
							<option value="3">三级医院</option>
						</select>
					</td>
    			</tr>
    			<tr>
    				<td>所在省</td>
    				<td><input type="text" name="province" id="province" value="${hospital.province}" placeholder="选填"/></td>
    				<td>所在市</td><td>
    				<input type="text" name="city" id="city" value="${hospital.city}" placeholder="选填" /></td>
    			</tr>
    			<tr>
    				<td>电话</td>
    				<td><input type="text" name="phone" id="phone" value="${hospital.phone}" placeholder="选填"/></td>
    				<td>具体地址</td>
    				<td><input type="text" name="address" id="address" value="${hospital.address}" placeholder="选填"/></td>
    			</tr>
				<tr>
					<td>网址</td>
					<td><input type="text" name="netaddress" id="netaddress" value="${hospital.netaddress}" placeholder="选填"/></td>
					<td>描述</td>
					<td><input type="text" name="description" id="description" value="${hospital.description}" placeholder="选填"/></td>
				</tr>
    			<tr>
					<td colspan="10">
						<a  style="margin-left: 66px"  href="javascript:save();">确定</a>
						<a href="javascript:top.Dialog.close();">取消</a>
					</td>
				</tr>
    	</table>
    </form>
  </body>
  <script type="text/javascript">
  $(function($){
  	var id=$('#id').val();
  	if(id !=null && id != ""){
			$("#type").val("${hospital.type}");

  	};
  
  });
  function save(){
  	var name = $('#name').val().trim();
  	if(name === null || name === ''){
  		$('#name').tips({
  			side:3,
  			msg:'医院名不能为空！',
  			bg:'#AE81FF',
  			time:3
  		});
  		$('#name').focus();
  		return false;
  	}

  	var id = '${hospital.id}';
  	if(id == '' || id == null || id == undefined){
		$.ajax({
			cache: true,
			type: "POST",
			url:'<%=basePath%>hs/hospital/save.do',
			data:$('#saveForm').serialize(),
			async: false,
			error: function(request) {
				layer.msg('<span style="color:white;">插入数据出错 !</span>');
			},
			success: function(data) {
				if(data=true){
					top.Dialog.close();
				}else{
					layer.msg('<span style="color:white;">插入数据出错 !</span>');
				}
			}
		});
	}else{
		$.ajax({
             cache: true,
             type: "POST",
             url:'<%=basePath%>hs/hospital/save.do',
             data:$('#saveForm').serialize(),
             async: false,
             error: function(request) {
             layer.msg('<span style="color:white;">更新数据出错 !</span>');
             },
             success: function(data) {
             	if(data=true){
                	top.Dialog.close();
                }
             }
         });
	}

  	
  }
  </script>
</html>
